#ifndef LIBTRANS_SERVER_H
#define LIBTRANS_SERVER_H

#include "trans.h"
/* for server */
struct TRANSMsg {
	TRANSMSG msg;       /* what this message means */
	TRANS *singal_handle; /* the handle it concerns */
	union {
		void *whatever;    /* message-specific data */
		TRANScode result;   /* return code for transfer */
	}data;
};
/*
When msg is TRANSMSG_DONE, the message identifies a transfer that
is done, and then result contains the return code for the easy handle
that just completed.
*/

TRANS *trans_server_init(TRANSoption cmd);	//set block or nonblock
TRANScode trans_server_setopt(TRANS *trans, TRANSoption tag, ...);
TRANScode trans_server_perform(TRANS *trans);	//replay
void trans_server_cleanup(TRANS *handle);
TRANSM *trans_mserver_init(int n);	//how many?
TRANSMcode trans_mserver_add_event(TRANSM *multi_handle, TRANS *singal_handle, TRANSMoption event_code);	//add event
TRANSMcode trans_mserver_remove_event(TRANSM *multi_handle, TRANS *singal_handle, TRANSMoption event_code);	//delete event
TRANSMcode trans_mserver_add_handle(TRANSM *multi_handle, TRANS *singal_handle);
TRANSMcode trans_mserver_remove_handle(TRANSM *multi_handle, TRANS *singal_handle);
/*timeout is in milliseconds, -1 wait indefinitely, 0 return immediately*/
TRANSMcode trans_mserver_perform(TRANSM *multi_handle, int *running_handles, int timeout);
TRANSMsg *trans_mserver_info_read(TRANSM *multi_handle, int *msgs_in_queue);	//return TRANSMsg array
void trans_mserver_cleanup(TRANSM *handle);
#endif
